use std::{fs::File, io::{self, Read}, num::{self}, ops::FromResidual};



enum MyError{
    Io(io::Error),
    PaseError(num::ParseIntError)
}

impl From<io::Error> for MyError {
    fn from(value: io::Error) -> Self {
        Self::Io(value)
    }
}

impl From<num::ParseIntError> for MyError {
    fn from(value: num::ParseIntError) -> Self {
        Self::PaseError(value)
    }
}

struct aaa {
}

// ? 问号可以作用在 FromResidual 特征上
impl FromResidual for aaa {
    fn from_residual(residual: <Self as std::ops::Try>::Residual) -> Self {
        aaa {}
    }
}

fn test1() -> Result<String, MyError> {
    let mut a = String::new();
    let _ = File::open("hello.txt")?.read_to_string(&mut a)?;
    // fs::read_to_string("hello.txt")?;
    let num: i32 = "33".parse()?; // 根据 接受变量推断泛型
    let _ = "22".parse::<i32>()?; // 直接标注泛型
    Ok(a)
}


fn main() {
    panic!("aaaaaa");
}
